package com.jiuyou.clientController.mall.bind;

import com.jiuyou.clientController.base.ClientBaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.shopping.domain.MallBind;
import com.ruoyi.shopping.service.IMallBindService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author chengliang
 * @date 2022/8/3
 **/
@RestController
@RequestMapping("/client/mall/bind")
public class MallBindClientController extends ClientBaseController {
    @Autowired
    private IMallBindService bindService;

    @RequestMapping("/bind/{storeId}")
    public AjaxResult bind(@PathVariable Long storeId){
        MallBind bind = new MallBind();
        bind.setMemberId(getLoginMemberId());
        bind.setStoreId(storeId);
        List<MallBind> mallBinds = bindService.selectMallBindList(bind);
        if(mallBinds.size()>0){
            return AjaxResult.success();
        }
        bindService.insertMallBind(bind);
        return AjaxResult.success();
    }

}
